package com.example.mapper;

import com.example.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface UserMapper
{

    @Select("select * from user_ where id = #{id}")
        User selectByUserid(Integer id);


//    @Insert("insert into student (username,password,name,phone,email,sex,birth,avatar,role)" +
//            "values (#{username},#{password},#{name},#{phone},#{email},#{sex},#{birth},#{avatar},#{role})")
    @Insert("insert into user_(name,password,role,sex,address,phone,email)"+
      "values (#{name},#{password},#{role},#{sex},#{address},#{phone},#{email})  ")
    void insert(User user);

    /*
    * 修改
     */
//    @Update("UPDATE user_ SET name=#{name}, password=#{password},  " +
//            "sex=#{sex}, address=#{address}, phone=#{phone}, email=#{email} " +
//            "WHERE id=#{id}")
//    void updateById(User user);

    @Delete("delete from user_ where id= #{id}")
    void deleteById(Integer id);

//    @Select("select * from user_ where id like concat('%',#{id},'%') and name like concat('%',#{name},'%')")
    List<User> selectAll(User user);

    @Update("UPDATE user_ SET name=#{name}, password=#{password},  " +
            "sex=#{sex}, address=#{address}, phone=#{phone}, email=#{email} " +
            "WHERE id=#{id}")
    void updateInfoByid(User user);
}

